﻿@model IEnumerable<TopicNode>
@{
    ViewData["Title"] = "版块管理";
}
<p>
    <a asp-action="Create" asp-route-parentid="0">新增父版块</a>
</p>
<div id="sections" class="panel panel-default">
    <div class="panel-heading">版块列表</div>
    <div class="panel-body">
        <div class="table-responsive">
            <table class="table table-striped">
                <thead>
                    <tr>
                        <th>
                            名称
                        </th>
                        <th>
                            节点别名
                        </th>
                        <th>
                            排序
                        </th>
                        <th>
                            父节点
                        </th>
                        <th>
                            描述
                        </th>
                        <th>
                            创建时间
                        </th>
                        <th></th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var item in Model.Where(r => r.ParentId == 0).OrderBy(r => r.Order))
                    {
                    <tr>
                        <td>
                            @Html.DisplayFor(modelItem => item.Name)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.NodeName)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.Order)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.ParentId)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.Description)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.CreateOn)
                        </td>
                        <td>
                            <a asp-action="Create" asp-route-parentid="@item.Id">新增子节点</a>|
                            <a asp-action="Edit" asp-route-id="@item.Id">编辑</a> |
                            <a asp-action="Delete" asp-route-id="@item.Id">删除</a>
                        </td>
                    </tr>
                        foreach (var node in Model.Where(r => r.ParentId == item.Id).OrderBy(r => r.Order))
                        {
                    <tr>
                        <td>
                            -->@Html.DisplayFor(modelItem => node.Name)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => node.NodeName)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => node.Order)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => node.ParentId)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => node.Description)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => node.CreateOn)
                        </td>
                        <td>
                            <a asp-action="Edit" asp-route-id="@node.Id">编辑</a> |
                            <a asp-action="Delete" asp-route-id="@node.Id">删除</a>
                        </td>
                    </tr>
                        }
                    }
                </tbody>
            </table>
        </div>
    </div>
</div>
